package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.PersonalAwards;
import com.ruoyi.system.service.IPersonalAwardsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 个人奖励情况Controller
 * 
 * @author ruoyi
 * @date 2025-05-22
 */
@Api(tags = "个人奖励情况管理")
@RestController
@RequestMapping("/system/awards")
public class PersonalAwardsController extends BaseController
{
    @Autowired
    private IPersonalAwardsService personalAwardsService;

    /**
     * 查询个人奖励情况列表
     */
    @ApiOperation(value = "查询奖励情况列表")
    @PreAuthorize("@ss.hasPermi('system:awards:list')")
    @GetMapping("/list")
    public TableDataInfo list(PersonalAwards personalAwards)
    {
        startPage();
        List<PersonalAwards> list = personalAwardsService.selectPersonalAwardsList(personalAwards);
        return getDataTable(list);
    }

    /**
     * 导出个人奖励情况列表
     */
    @ApiOperation(value = "个人奖励情况列表")
    @PreAuthorize("@ss.hasPermi('system:awards:export')")
    @Log(title = "个人奖励情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PersonalAwards personalAwards)
    {
        List<PersonalAwards> list = personalAwardsService.selectPersonalAwardsList(personalAwards);
        ExcelUtil<PersonalAwards> util = new ExcelUtil<PersonalAwards>(PersonalAwards.class);
        util.exportExcel(response, list, "个人奖励情况数据");
    }

    /**
     * 获取个人奖励情况详细信息
     */
    @ApiOperation(value = "获取个人奖励情况详细信息")
    @PreAuthorize("@ss.hasPermi('system:awards:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(personalAwardsService.selectPersonalAwardsById(id));
    }

    /**
     * 新增个人奖励情况
     */
    @ApiOperation(value = "新增个人奖励情况")
    @PreAuthorize("@ss.hasPermi('system:awards:add')")
    @Log(title = "个人奖励情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PersonalAwards personalAwards)
    {
        return toAjax(personalAwardsService.insertPersonalAwards(personalAwards));
    }

    /**
     * 修改个人奖励情况
     */
    @ApiOperation(value = "修改个人奖励情况")
    @PreAuthorize("@ss.hasPermi('system:awards:edit')")
    @Log(title = "个人奖励情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PersonalAwards personalAwards)
    {
        return toAjax(personalAwardsService.updatePersonalAwards(personalAwards));
    }

    /**
     * 删除个人奖励情况
     */
    @ApiOperation(value = "删除个人奖励情况")
    @PreAuthorize("@ss.hasPermi('system:awards:remove')")
    @Log(title = "个人奖励情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(personalAwardsService.deletePersonalAwardsByIds(ids));
    }
}
